In [8]:
import plotly.plotly as py
import cufflinks as cf
import pandas as pd
import numpy as np
import json
with open("/Users/Alan/.plotly/.credentials", 'rb') as fi:
cred= json.load(fi, encoding='utf-8')
myapi = cred['api_key']
username = cred['username']
py.sign_in(username, myapi)
In [34]:
b = pd.read_pickle("../yelp-challenge/data_all_cities/all_cities_preprocess.pkl")
area = pd.read_pickle("../yelp-challenge/data_processeing/spatial_labels.pkl")
area_star = b[['stars']].join(area)
T_star = area_star[area_star.spatial_label == 3].groupby('stars').size()
P_star = area_star[area_star.spatial_label == 2].groupby('stars').size()
L_star = area_star[area_star.spatial_label == 7].groupby('stars').size()
stars = pd.concat([T_star,P_star,L_star], axis=1)
print area_star.stars.max(), area_star.stars.min()
print len(area_star.stars.unique())
stars = pd.concat([T_star,P_star,L_star], axis=1)
stars.index = stars.index.values
stars.columns = ['The Greater Torronto Area', 'The Greater Phoenix Area', 'The Greater Las Vegas Area']
In [73]:
stars.iplot(kind='area', fill=True, title='Distribution of Rating Stars in Target Areas', xTitle='Rating Star', yTitle='The Number of Restaurants',bins=9)
Out[73]: